﻿#region Copyright
// Copyright (c) 2011-2012 RaisingForce Team (Alikin Sergey)
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#endregion

using System;
using System.Diagnostics.Contracts;
using System.Windows;
using RaisingForce.Raise.Presentation.ViewModel;
using RaisingForce.Raise.Presentation.Controls;

namespace RaisingForce.RaiseHardwareTest
{
    /// <summary>
    /// Логика взаимодействия для DialogWindow.xaml
    /// </summary>
    public partial class ModelWindow :
        ModelWindowBase
    {
        #region Constructors

        private ModelWindow(WindowViewModel content)
            : base()
        {
            Contract.Requires(content != null);
            this.SetupContent(content);
            InitializeComponent();
            this.content.Content = content;
        }

        #endregion

        #region Show Static Method

        public static Result Show(
            WindowViewModel content,
            ModelWindowShowMode showMode = ModelWindowShowMode.Normal,
            Window owner = null,
            double width = 0,
            double height = 0,
            bool showInTaskbar = true,
            WindowStartupLocation startupLocation = WindowStartupLocation.CenterOwner,
            Action<Window> prologAction = null)
        {
            Contract.Requires(content != null);
            Contract.Requires(Enum.IsDefined(typeof(ModelWindowShowMode), showMode));
            Contract.Requires(Enum.IsDefined(typeof(WindowStartupLocation), startupLocation));
            Contract.Ensures(Contract.Result<Result>() != null);
            ModelWindowBase window =
                ModelWindowBase.IsEmulation(showMode) ?
                ModelWindowBase.CreateEmulationWindow() :
                new ModelWindow(content);
            return ModelWindowBase.Show(
                window,
                showMode,
                owner,
                width,
                height,
                startupLocation,
                showInTaskbar,
                prologAction);
        }

        #endregion
    }
}
